//
// Created by 吴锐 on 2022/3/2.
//

#include "iostream"
#include "vector"
#include "string"
#include "map"

#define CE_HUA 1
#define MEI_SHU 2
#define YAN_FA 3

using namespace std;

class Worker {
public:
    string m_Name;
    int m_Salary;
};

void createWorkerVector(vector<Worker>& workerVector){
    string nameSeed = "ADCBEFGHIJ";
    for(int i = 0 ; i < 10 ; i++){
        Worker worker;
        worker.m_Name = "员工";
        worker.m_Name += nameSeed[i];

        worker.m_Salary = rand() % 10000 + 10000;
        workerVector.push_back(worker);
    }
}

void setGroup(vector<Worker>& workerVector, multimap<int, Worker>& workerMap){
    for(vector<Worker>::iterator it = workerVector.begin() ; it != workerVector.end() ; it++){
        int deptId = rand() % 3 + 1;
        workerMap.insert(make_pair(deptId, *it));
    }
}

void showWorkerByCroup(multimap<int, Worker>& workerMap){
    cout << "策划部门: " << endl;
    multimap<int, Worker>::iterator currentIndex = workerMap.find(CE_HUA);
    int count = workerMap.count(CE_HUA);
    int currentCount = 0;
    for(; currentIndex != workerMap.end() && currentCount < count; currentIndex++, currentCount++){
        cout << "姓名: " << currentIndex->second.m_Name << " 工资: " << currentIndex->second.m_Salary << endl;
    }
    cout << "美术部门: " << endl;
    multimap<int, Worker>::iterator currentIndex2 = workerMap.find(MEI_SHU);
    int count2 = workerMap.count(MEI_SHU);
    int currentCount2 = 0;
    for(; currentIndex2 != workerMap.end() && currentCount2 < count2; currentIndex2++, currentCount2++){
        cout << "姓名: " << currentIndex2->second.m_Name << " 工资: " << currentIndex2->second.m_Salary << endl;
    }
    cout << "研发部门: " << endl;
    multimap<int, Worker>::iterator currentIndex3 = workerMap.find(YAN_FA);
    int count3 = workerMap.count(YAN_FA);
    int currentCount3 = 0;
    for(; currentIndex3 != workerMap.end() && currentCount3 < count3; currentIndex3++, currentCount3++){
        cout << "姓名: " << currentIndex3->second.m_Name << " 工资: " << currentIndex3->second.m_Salary << endl;
    }
}

int main(){
    vector<Worker> workerVector;
    createWorkerVector(workerVector);
//    for(vector<Worker>::iterator it = workerVector.begin() ; it != workerVector.end() ; it++){
//        cout << "姓名: " << it->m_Name << " 工资: " << it->m_Salary << endl;
//    }
    multimap<int, Worker> workerMap;
    setGroup(workerVector, workerMap);
    showWorkerByCroup(workerMap);
    return 0;
}